/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.documentar.view;

import br.com.documentar.controller.ColunaController;
import br.com.documentar.controller.ProdutoController;
import br.com.documentar.controller.TabelaController;
import br.com.documentar.controller.VersaoController;
import br.com.documentar.interfacee.InterfaceView;
import br.com.documentar.model.AssociarColunaVersaoModel;
import br.com.documentar.model.ColunaModel;
import br.com.documentar.model.ProdutoModel;
import br.com.documentar.model.TabelaModel;
import br.com.documentar.model.VersaoModel;
import br.com.documentar.util.UtilitariosCampos;
import br.com.documentar.util.setFiltroCampo;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;

/**
 *
 * @author Santos
 */
public class AssociarColunaVersaoView extends javax.swing.JFrame implements InterfaceView<br.com.documentar.model.AssociarColunaVersaoModel> {

    private br.com.documentar.controller.AssociarColunaVersaoController control = new br.com.documentar.controller.AssociarColunaVersaoController();
    private br.com.documentar.model.AssociarColunaVersaoModel model = control.getModel();

    /**
     * Creates new form ProdutoController
     */
    public AssociarColunaVersaoView() {
        initComponents();
        Start();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabbedPaneManutencao = new javax.swing.JTabbedPane();
        panelConsulta = new javax.swing.JPanel();
        jLabelNome = new javax.swing.JLabel();
        textFieldConsultar = new javax.swing.JTextField();
        jScrollPanelConsulta = new javax.swing.JScrollPane();
        jTableConsulta = new javax.swing.JTable();
        panelAbaACadastro = new javax.swing.JPanel();
        jScrollPaneManutencaoA = new javax.swing.JScrollPane();
        jPanelManutencaoA = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        comboBoxTabela = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        comboBoxProduto = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        comboBoxTipoDado = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        textFieldTamanho = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        comboBoxAceitaNull = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        textFieldValorPadrao = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        comboBoxAutoIncremento = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        comboBoxChavePrimaria = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        comboBoxChaveEstrangeira = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        comboBoxChaveUnica = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        comboBoxTemCheck = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        comboBoxAtivo = new javax.swing.JComboBox();
        jLabel17 = new javax.swing.JLabel();
        comboBoxVersao = new javax.swing.JComboBox();
        jLabel18 = new javax.swing.JLabel();
        comboBoxColuna = new javax.swing.JComboBox();
        jLabel19 = new javax.swing.JLabel();
        comboBoxAcao = new javax.swing.JComboBox();
        panelAbaBCadastro = new javax.swing.JPanel();
        jScrollPaneManutencaoA1 = new javax.swing.JScrollPane();
        jPanelManutencaoB = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textAreaSQL = new javax.swing.JTextArea();
        panelAbaRelatorio = new javax.swing.JPanel();
        toolBarManutencao = new javax.swing.JToolBar();
        buttonConsultar = new javax.swing.JButton();
        buttonNovo = new javax.swing.JButton();
        buttonEditar = new javax.swing.JButton();
        buttonExcluir = new javax.swing.JButton();
        buttonCancelar = new javax.swing.JButton();
        buttonGravar = new javax.swing.JButton();
        buttonRelatorio = new javax.swing.JButton();
        buttonAnterior = new javax.swing.JButton();
        buttonProximo = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Associar Coluna à Versão");

        jLabelNome.setText("Pesquisar:");

        jTableConsulta.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTableConsulta.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jTableConsulta.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jTableConsulta.getTableHeader().setReorderingAllowed(false);
        jScrollPanelConsulta.setViewportView(jTableConsulta);

        javax.swing.GroupLayout panelConsultaLayout = new javax.swing.GroupLayout(panelConsulta);
        panelConsulta.setLayout(panelConsultaLayout);
        panelConsultaLayout.setHorizontalGroup(
            panelConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelConsultaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelNome)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textFieldConsultar, javax.swing.GroupLayout.DEFAULT_SIZE, 523, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jScrollPanelConsulta, javax.swing.GroupLayout.DEFAULT_SIZE, 597, Short.MAX_VALUE)
        );
        panelConsultaLayout.setVerticalGroup(
            panelConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelConsultaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelConsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNome)
                    .addComponent(textFieldConsultar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPanelConsulta, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE))
        );

        tabbedPaneManutencao.addTab("Consulta", panelConsulta);

        jLabel5.setText("Tabela:");

        comboBoxTabela.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER" }));

        jLabel6.setText("Produto:");

        comboBoxProduto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER" }));

        jLabel3.setText("Tipo de Dado:");

        comboBoxTipoDado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER", "INTEGER", "LONG", "NUMBER", "CHAR", "CLOB", "DATE", "VARCHAR", "VARCHAR2", "BLOB", "ROWID", "REG_SZ", "REG_DWORD", "REG_BINARY" }));

        jLabel8.setText("Tamanho:");

        jLabel9.setText("Aceita Null:");

        comboBoxAceitaNull.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER", "S - Sim", "N - Não" }));

        jLabel10.setText("Valor Padrão:");

        jLabel11.setText("Auto Incrementado:");

        comboBoxAutoIncremento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER", "S - Sim", "N - Não" }));

        jLabel12.setText("Chave Primária:");

        comboBoxChavePrimaria.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER", "S - Sim", "N - Não" }));

        jLabel13.setText("Chave Estrangeira:");

        comboBoxChaveEstrangeira.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER", "S - Sim", "N - Não" }));

        jLabel14.setText("Chave Única:");

        comboBoxChaveUnica.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER", "S - Sim", "N - Não" }));

        jLabel15.setText("Tem Check:");

        comboBoxTemCheck.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER", "S - Sim", "N - Não" }));

        jLabel16.setText("Ativo:");

        comboBoxAtivo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER", "S - Sim", "N - Não" }));

        jLabel17.setText("Versão:");

        comboBoxVersao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER" }));

        jLabel18.setText("Coluna:");

        comboBoxColuna.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER" }));

        jLabel19.setText("Ação:");

        comboBoxAcao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESCOLHER", "I - Inclusão", "U - Alteração", "D - Remoção" }));

        javax.swing.GroupLayout jPanelManutencaoALayout = new javax.swing.GroupLayout(jPanelManutencaoA);
        jPanelManutencaoA.setLayout(jPanelManutencaoALayout);
        jPanelManutencaoALayout.setHorizontalGroup(
            jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelManutencaoALayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelManutencaoALayout.createSequentialGroup()
                        .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel8)
                            .addComponent(jLabel9)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12)
                            .addComponent(jLabel13)
                            .addComponent(jLabel14)
                            .addComponent(jLabel15)
                            .addComponent(jLabel19)
                            .addComponent(jLabel16))
                        .addGap(63, 63, 63)
                        .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textFieldTamanho)
                            .addComponent(comboBoxAceitaNull, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(textFieldValorPadrao)
                            .addComponent(comboBoxAutoIncremento, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(comboBoxChavePrimaria, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboBoxChaveEstrangeira, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboBoxChaveUnica, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboBoxTemCheck, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboBoxAcao, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboBoxAtivo, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboBoxTipoDado, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanelManutencaoALayout.createSequentialGroup()
                        .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel17)
                            .addComponent(jLabel5)
                            .addComponent(jLabel18))
                        .addGap(118, 118, 118)
                        .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(comboBoxColuna, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboBoxTabela, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboBoxVersao, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboBoxProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(157, Short.MAX_VALUE))
        );

        jPanelManutencaoALayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboBoxAcao, comboBoxAceitaNull, comboBoxAtivo, comboBoxAutoIncremento, comboBoxChaveEstrangeira, comboBoxChavePrimaria, comboBoxChaveUnica, comboBoxColuna, comboBoxProduto, comboBoxTabela, comboBoxTemCheck, comboBoxTipoDado, comboBoxVersao, textFieldTamanho, textFieldValorPadrao});

        jPanelManutencaoALayout.setVerticalGroup(
            jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelManutencaoALayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(comboBoxProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(comboBoxVersao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboBoxTabela, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(comboBoxColuna, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboBoxTipoDado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(textFieldTamanho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(comboBoxAceitaNull, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(textFieldValorPadrao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(comboBoxAutoIncremento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(comboBoxChavePrimaria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(comboBoxChaveEstrangeira, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(comboBoxChaveUnica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(comboBoxTemCheck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(comboBoxAcao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelManutencaoALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboBoxAtivo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanelManutencaoALayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboBoxAcao, comboBoxAceitaNull, comboBoxAtivo, comboBoxAutoIncremento, comboBoxChaveEstrangeira, comboBoxChavePrimaria, comboBoxChaveUnica, comboBoxColuna, comboBoxProduto, comboBoxTabela, comboBoxTemCheck, comboBoxTipoDado, comboBoxVersao, textFieldTamanho, textFieldValorPadrao});

        jScrollPaneManutencaoA.setViewportView(jPanelManutencaoA);

        javax.swing.GroupLayout panelAbaACadastroLayout = new javax.swing.GroupLayout(panelAbaACadastro);
        panelAbaACadastro.setLayout(panelAbaACadastroLayout);
        panelAbaACadastroLayout.setHorizontalGroup(
            panelAbaACadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneManutencaoA)
        );
        panelAbaACadastroLayout.setVerticalGroup(
            panelAbaACadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneManutencaoA)
        );

        tabbedPaneManutencao.addTab("Pagina A", panelAbaACadastro);

        jLabel2.setText("SQL:");

        textAreaSQL.setColumns(20);
        textAreaSQL.setRows(5);
        jScrollPane1.setViewportView(textAreaSQL);

        javax.swing.GroupLayout jPanelManutencaoBLayout = new javax.swing.GroupLayout(jPanelManutencaoB);
        jPanelManutencaoB.setLayout(jPanelManutencaoBLayout);
        jPanelManutencaoBLayout.setHorizontalGroup(
            jPanelManutencaoBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelManutencaoBLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanelManutencaoBLayout.setVerticalGroup(
            jPanelManutencaoBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelManutencaoBLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelManutencaoBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1)
                    .addGroup(jPanelManutencaoBLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jScrollPaneManutencaoA1.setViewportView(jPanelManutencaoB);

        javax.swing.GroupLayout panelAbaBCadastroLayout = new javax.swing.GroupLayout(panelAbaBCadastro);
        panelAbaBCadastro.setLayout(panelAbaBCadastroLayout);
        panelAbaBCadastroLayout.setHorizontalGroup(
            panelAbaBCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneManutencaoA1)
        );
        panelAbaBCadastroLayout.setVerticalGroup(
            panelAbaBCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneManutencaoA1, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
        );

        tabbedPaneManutencao.addTab("Pagina B", panelAbaBCadastro);

        javax.swing.GroupLayout panelAbaRelatorioLayout = new javax.swing.GroupLayout(panelAbaRelatorio);
        panelAbaRelatorio.setLayout(panelAbaRelatorioLayout);
        panelAbaRelatorioLayout.setHorizontalGroup(
            panelAbaRelatorioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 597, Short.MAX_VALUE)
        );
        panelAbaRelatorioLayout.setVerticalGroup(
            panelAbaRelatorioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 409, Short.MAX_VALUE)
        );

        tabbedPaneManutencao.addTab("Relatório", panelAbaRelatorio);

        toolBarManutencao.setFloatable(false);
        toolBarManutencao.setRollover(true);

        buttonConsultar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/documentar/iconesManutencoes/application_form_magnify.png"))); // NOI18N
        buttonConsultar.setMnemonic('l');
        buttonConsultar.setText("Consultar");
        buttonConsultar.setFocusable(false);
        buttonConsultar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buttonConsultar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buttonConsultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonConsultarActionPerformed(evt);
            }
        });
        toolBarManutencao.add(buttonConsultar);

        buttonNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/documentar/iconesManutencoes/application_add.png"))); // NOI18N
        buttonNovo.setMnemonic('N');
        buttonNovo.setText("Novo");
        buttonNovo.setFocusable(false);
        buttonNovo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buttonNovo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buttonNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonNovoActionPerformed(evt);
            }
        });
        toolBarManutencao.add(buttonNovo);

        buttonEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/documentar/iconesManutencoes/application_edit.png"))); // NOI18N
        buttonEditar.setMnemonic('E');
        buttonEditar.setText("Editar");
        buttonEditar.setFocusable(false);
        buttonEditar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buttonEditar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buttonEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonEditarActionPerformed(evt);
            }
        });
        toolBarManutencao.add(buttonEditar);

        buttonExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/documentar/iconesManutencoes/application_delete.png"))); // NOI18N
        buttonExcluir.setMnemonic('x');
        buttonExcluir.setText("Excluir");
        buttonExcluir.setFocusable(false);
        buttonExcluir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buttonExcluir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buttonExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonExcluirActionPerformed(evt);
            }
        });
        toolBarManutencao.add(buttonExcluir);

        buttonCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/documentar/iconesManutencoes/cancel.png"))); // NOI18N
        buttonCancelar.setMnemonic('C');
        buttonCancelar.setText("Cancelar");
        buttonCancelar.setFocusable(false);
        buttonCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buttonCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buttonCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCancelarActionPerformed(evt);
            }
        });
        toolBarManutencao.add(buttonCancelar);

        buttonGravar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/documentar/iconesManutencoes/accept.png"))); // NOI18N
        buttonGravar.setMnemonic('a');
        buttonGravar.setText("Gravar");
        buttonGravar.setFocusable(false);
        buttonGravar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buttonGravar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buttonGravar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonGravarActionPerformed(evt);
            }
        });
        toolBarManutencao.add(buttonGravar);

        buttonRelatorio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/documentar/iconesManutencoes/application_side_list.png"))); // NOI18N
        buttonRelatorio.setMnemonic('R');
        buttonRelatorio.setText("Relatório");
        buttonRelatorio.setFocusable(false);
        buttonRelatorio.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buttonRelatorio.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buttonRelatorio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonRelatorioActionPerformed(evt);
            }
        });
        toolBarManutencao.add(buttonRelatorio);

        buttonAnterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/documentar/iconesManutencoes/arrow_left.png"))); // NOI18N
        buttonAnterior.setMnemonic('o');
        buttonAnterior.setText("Anterior");
        buttonAnterior.setFocusable(false);
        buttonAnterior.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buttonAnterior.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buttonAnterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonAnteriorActionPerformed(evt);
            }
        });
        toolBarManutencao.add(buttonAnterior);

        buttonProximo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/documentar/iconesManutencoes/arrow_right.png"))); // NOI18N
        buttonProximo.setMnemonic('m');
        buttonProximo.setText("Próximo");
        buttonProximo.setFocusable(false);
        buttonProximo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buttonProximo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buttonProximo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonProximoActionPerformed(evt);
            }
        });
        toolBarManutencao.add(buttonProximo);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabbedPaneManutencao)
            .addComponent(toolBarManutencao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(toolBarManutencao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tabbedPaneManutencao))
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void buttonConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConsultarActionPerformed
        Consultar();
    }//GEN-LAST:event_buttonConsultarActionPerformed

    private void buttonNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonNovoActionPerformed
        CarregarNovoDados();
    }//GEN-LAST:event_buttonNovoActionPerformed

    private void buttonEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEditarActionPerformed
        CarregarEditarDados();
    }//GEN-LAST:event_buttonEditarActionPerformed

    private void buttonExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExcluirActionPerformed
        CarregarExcluirDados();
    }//GEN-LAST:event_buttonExcluirActionPerformed

    private void buttonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelarActionPerformed
        CancelarOperacao();
    }//GEN-LAST:event_buttonCancelarActionPerformed

    private void buttonGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGravarActionPerformed
        GravarDados();
    }//GEN-LAST:event_buttonGravarActionPerformed

    private void buttonRelatorioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRelatorioActionPerformed
        tabbedPaneManutencao.setSelectedIndex(2);
    }//GEN-LAST:event_buttonRelatorioActionPerformed

    private void buttonAnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAnteriorActionPerformed
        ProximaAba("Anterior");
    }//GEN-LAST:event_buttonAnteriorActionPerformed

  private void buttonProximoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonProximoActionPerformed
      ProximaAba("Proximo");
  }//GEN-LAST:event_buttonProximoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main() {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AssociarColunaVersaoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AssociarColunaVersaoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AssociarColunaVersaoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AssociarColunaVersaoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AssociarColunaVersaoView().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonAnterior;
    private javax.swing.JButton buttonCancelar;
    protected javax.swing.JButton buttonConsultar;
    private javax.swing.JButton buttonEditar;
    private javax.swing.JButton buttonExcluir;
    private javax.swing.JButton buttonGravar;
    private javax.swing.JButton buttonNovo;
    private javax.swing.JButton buttonProximo;
    private javax.swing.JButton buttonRelatorio;
    private javax.swing.JComboBox comboBoxAcao;
    private javax.swing.JComboBox comboBoxAceitaNull;
    private javax.swing.JComboBox comboBoxAtivo;
    private javax.swing.JComboBox comboBoxAutoIncremento;
    private javax.swing.JComboBox comboBoxChaveEstrangeira;
    private javax.swing.JComboBox comboBoxChavePrimaria;
    private javax.swing.JComboBox comboBoxChaveUnica;
    private javax.swing.JComboBox comboBoxColuna;
    private javax.swing.JComboBox comboBoxProduto;
    private javax.swing.JComboBox comboBoxTabela;
    private javax.swing.JComboBox comboBoxTemCheck;
    private javax.swing.JComboBox comboBoxTipoDado;
    private javax.swing.JComboBox comboBoxVersao;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelNome;
    private javax.swing.JPanel jPanelManutencaoA;
    private javax.swing.JPanel jPanelManutencaoB;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPaneManutencaoA;
    private javax.swing.JScrollPane jScrollPaneManutencaoA1;
    private javax.swing.JScrollPane jScrollPanelConsulta;
    private javax.swing.JTable jTableConsulta;
    private javax.swing.JPanel panelAbaACadastro;
    private javax.swing.JPanel panelAbaBCadastro;
    private javax.swing.JPanel panelAbaRelatorio;
    private javax.swing.JPanel panelConsulta;
    private javax.swing.JTabbedPane tabbedPaneManutencao;
    private javax.swing.JTextArea textAreaSQL;
    private javax.swing.JTextField textFieldConsultar;
    private javax.swing.JTextField textFieldTamanho;
    private javax.swing.JTextField textFieldValorPadrao;
    private javax.swing.JToolBar toolBarManutencao;
    // End of variables declaration//GEN-END:variables

    @Override
    public void CarregarEditarDados() {
        model.setActionScript("U");
        if (jTableConsulta.getSelectedRow() != -1) {
            AssociarColunaVersaoModel associarColunaVersaoModel
                    = model.getColunaVersao(
                            UtilitariosCampos.getIntegerTable(jTableConsulta, 1),
                            UtilitariosCampos.getIntegerTable(jTableConsulta, 2),
                            UtilitariosCampos.getIntegerTable(jTableConsulta, 3));

            comboBoxProduto.setSelectedItem(associarColunaVersaoModel.getProduto().getCodigo() + " - " + associarColunaVersaoModel.getProduto().getNome());
            comboBoxVersao.setSelectedItem(associarColunaVersaoModel.getVersao().getCodigo() + " - " + associarColunaVersaoModel.getVersao().getNome());
            comboBoxTabela.setSelectedItem(associarColunaVersaoModel.getColuna().getTabela().getCodigo() + " - " + associarColunaVersaoModel.getColuna().getTabela().getNome());
            comboBoxColuna.setSelectedItem(associarColunaVersaoModel.getColuna().getCodigo() + " - " + associarColunaVersaoModel.getColuna().getNome());
            comboBoxTipoDado.setSelectedItem(associarColunaVersaoModel.getTipoDadoPadrao());
            textFieldTamanho.setText(UtilitariosCampos.getDoubleText(associarColunaVersaoModel.getTamanhoDadoPadrao()));
            UtilitariosCampos.setRespostaComboBox(comboBoxAceitaNull, associarColunaVersaoModel.getAceitaNullPadrao());
            //comboBoxAceitaNull.setSelectedItem(associarColunaVersaoModel.getAceitaNullPadrao() == 'S' ? "S - Sim" : "N - Não");
            textFieldValorPadrao.setText(associarColunaVersaoModel.getValorPadrao());
            //comboBoxAutoIncremento.setSelectedItem(associarColunaVersaoModel.getAutoIncrementoPadrao() == 'S' ? "S - Sim" : "N - Não");
            UtilitariosCampos.setRespostaComboBox(comboBoxAutoIncremento, associarColunaVersaoModel.getAutoIncrementoPadrao());
            UtilitariosCampos.setRespostaComboBox(comboBoxChavePrimaria, associarColunaVersaoModel.getChavePrimariaPadrao());
            UtilitariosCampos.setRespostaComboBox(comboBoxChaveEstrangeira, associarColunaVersaoModel.getChaveEstrangeiraPadrao());
            UtilitariosCampos.setRespostaComboBox(comboBoxChaveUnica, associarColunaVersaoModel.getChaveUnicaPadrao());
            UtilitariosCampos.setRespostaComboBox(comboBoxTemCheck, associarColunaVersaoModel.getTemCheckPadrao());

//            comboBoxChavePrimaria.setSelectedItem(associarColunaVersaoModel.getChavePrimariaPadrao() == 'S' ? "S - Sim" : "N - Não");
//            comboBoxChaveEstrangeira.setSelectedItem(associarColunaVersaoModel.getChaveEstrangeiraPadrao() == 'S' ? "S - Sim" : "N - Não");
//            comboBoxChaveUnica.setSelectedItem(associarColunaVersaoModel.getChaveUnicaPadrao() == 'S' ? "S - Sim" : "N - Não");
//            comboBoxTemCheck.setSelectedItem(associarColunaVersaoModel.getTemCheckPadrao() == 'S' ? "S - Sim" : "N - Não");
            comboBoxAcao.setSelectedItem(associarColunaVersaoModel.getAcao() == 'I' ? "I - Inclusão" : associarColunaVersaoModel.getAcao() == 'U' ? "U - Alteração" : "D - Remoção");
//            comboBoxAtivo.setSelectedItem(associarColunaVersaoModel.getAtivo() == 'S' ? "S - Sim" : "N - Não");
            UtilitariosCampos.setRespostaComboBox(comboBoxAtivo, associarColunaVersaoModel.getAtivo());
            textAreaSQL.setText(associarColunaVersaoModel.getSqlTextArea());
            
            tabbedPaneManutencao.setSelectedIndex(1);
            comboBoxTipoDado.requestFocus();
            comboBoxProduto.setEnabled(false);
            comboBoxVersao.setEnabled(false);
            comboBoxTabela.setEnabled(false);
            comboBoxColuna.setEnabled(false);
        } else {
            JOptionPane.showMessageDialog(rootPane, "Nenhuma linha selecionada");
        }
    }

    @Override
    public void CarregarNovoDados() {
        model.setActionScript("I");
        comboBoxProduto.setEnabled(true);
        comboBoxVersao.setEnabled(true);
        comboBoxTabela.setEnabled(true);
        comboBoxColuna.setEnabled(true);
        tabbedPaneManutencao.setSelectedIndex(1);
        comboBoxProduto.requestFocus();
    }

    @Override
    public void CarregarExcluirDados() {
        if (jTableConsulta.getSelectedRow() != -1) {
            AssociarColunaVersaoModel associarColunaVersaoModel
                    = model.getColunaVersao(
                            UtilitariosCampos.getIntegerTable(jTableConsulta, 1),
                            UtilitariosCampos.getIntegerTable(jTableConsulta, 2),
                            UtilitariosCampos.getIntegerTable(jTableConsulta, 3));
            associarColunaVersaoModel.setActionScript("D");
            control.setDados(associarColunaVersaoModel);
        } else {
            JOptionPane.showMessageDialog(rootPane, "Nenhuma linha selecionada");
        }
        Consultar();
    }

    @Override
    public void GravarDados() {
        if (model.getActionScript().equals("I") || model.getActionScript().equals("U")) {
            if (ValidaCampos()) {
                CarregarVariaveis();
                if (model.getActionScript().equals("I") && model.getColunaVersao(model.getVersao().getCodigo(), model.getColuna().getTabela().getCodigo(), model.getColuna().getCodigo()) != null) {
                    JOptionPane.showMessageDialog(panelConsulta, "Item já cadastrado na base de dados.");
                } else {
                    if (control.setDados(model)) {
                        Consultar();
                        LimparCampos();
                    }
                }
            }
        } else {
            JOptionPane.showMessageDialog(panelConsulta, "Você deve escolher uma ação clicando no botão Novo ou Editar.");
        }
    }

    @Override
    public void LimparCampos() {
        UtilitariosCampos.getLimpezaCampos(tabbedPaneManutencao);
    }

    @Override
    public void ProximaAba(String Movimento) {
        int a = tabbedPaneManutencao.getSelectedIndex();
        int quantidadeAba = tabbedPaneManutencao.getTabCount() - 1;
        if (Movimento.equals("Anterior")) {
            if (a != 0) {
                tabbedPaneManutencao.setSelectedIndex(a - 1);
            }
        } else if (Movimento.equals("Proximo")) {
            if (a != quantidadeAba) {
                tabbedPaneManutencao.setSelectedIndex(a + 1);
            }
        }
    }

    @Override
    public void TamanhoColunaTable() {
        int posicao = 0;
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 270);//produto
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 270);//versao
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 270);//tabela
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 270);//coluna
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 100);//tipo dado
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 100);//tamanho
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 100);//aceita null
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 100);//valor padrão
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 100);//auto incremento
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 100);//chave primaria
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 120);//chave estrangeira
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 120);//chave unica
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 100);//tem check
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 100);//ação
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 100);//ativo
        UtilitariosCampos.setTamanhoColunaTable(jTableConsulta, posicao++, 200);//SQL
    }

    @Override
    public void Consultar() {
        model.setActionScript("C");
        jTableConsulta.setModel(control.getDadosTableModel(model));
        tabbedPaneManutencao.setSelectedIndex(0);
        textFieldConsultar.requestFocus();
        TamanhoColunaTable();
    }

    @Override
    public void CommitCampos() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void CancelarOperacao() {
        LimparCampos();
        Consultar();
    }

    /**
     * Carregar variaveis para gravação dos dados
     */
    @Override
    public void CarregarVariaveis() {
        model.getColuna().getTabela().setCodigo(UtilitariosCampos.getIntegerComboBox(comboBoxTabela));
        model.getVersao().setCodigo(UtilitariosCampos.getIntegerComboBox(comboBoxVersao));
        model.getColuna().setCodigo(UtilitariosCampos.getIntegerComboBox(comboBoxColuna));

        model.setTipoDadoPadrao(comboBoxTipoDado.getSelectedItem().toString());
        model.setTamanhoDadoPadrao(UtilitariosCampos.getDoubleText(textFieldTamanho));
        model.setAceitaNullPadrao(UtilitariosCampos.getRespostaComboBox(comboBoxAceitaNull));
        model.setValorPadrao(textFieldValorPadrao.getText());
        model.setAutoIncrementoPadrao(UtilitariosCampos.getRespostaComboBox(comboBoxAutoIncremento));
        model.setChavePrimariaPadrao(UtilitariosCampos.getRespostaComboBox(comboBoxChavePrimaria));
        model.setChaveEstrangeiraPadrao(UtilitariosCampos.getRespostaComboBox(comboBoxChaveEstrangeira));
        model.setChaveUnicaPadrao(UtilitariosCampos.getRespostaComboBox(comboBoxChaveUnica));
        model.setTemCheckPadrao(UtilitariosCampos.getRespostaComboBox(comboBoxTemCheck));
        model.setAcao(UtilitariosCampos.getRespostaComboBox(comboBoxAcao));
        model.setAtivo(UtilitariosCampos.getRespostaComboBox(comboBoxAtivo));
        model.setSql(textAreaSQL.getText());
    }

    /**
     * Metodo responsável por reescrever o metodo que escuta o textField de
     * pesquisa
     */
    KeyAdapter pesquisaDados = new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {

            switch (e.getKeyCode()) {
                case KeyEvent.VK_ENTER://Botão Enter
                    model.setActionScript("P");
                    //model.setNome(textFieldConsultar.getText());
                    jTableConsulta.setModel(control.getDadosTableModel(model));
                    TamanhoColunaTable();
                    break;
            }
        }
    };

    ItemListener comboBoxProdutoListener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (!comboBoxProduto.getSelectedItem().toString().equals("ESCOLHER")
                    && e.getStateChange() == 2) {

                VersaoController versaoControl = new VersaoController();
                VersaoModel versaoModel = versaoControl.getModel();
                versaoModel.setActionScript("porProduto");
                versaoModel.getProduto().setCodigo(UtilitariosCampos.getIntegerComboBox(comboBoxProduto));
                comboBoxVersao.setModel(versaoControl.getDadosComboBoxModel(versaoModel));

                TabelaController tabelaControl = new TabelaController();
                TabelaModel tabelaModel = tabelaControl.getModel();
                tabelaModel.setActionScript("porProduto");
                tabelaModel.getProduto().setCodigo(UtilitariosCampos.getIntegerComboBox(comboBoxProduto));
                comboBoxTabela.setModel(tabelaControl.insertComboBoxModel(tabelaModel));
            }
        }
    };

    ItemListener comboBoxTabelaListener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (!comboBoxTabela.getSelectedItem().toString().equals("ESCOLHER")
                    && e.getStateChange() == 2) {

                ColunaController colunaControl = new ColunaController();
                ColunaModel colunaModel = colunaControl.getModel();
                colunaModel.setActionScript("porTabela");
                colunaModel.getTabela().setCodigo(UtilitariosCampos.getIntegerComboBox(comboBoxTabela));
                comboBoxColuna.setModel(colunaControl.getDadosComboBoxModel(colunaModel));
            }
        }
    };

    @Override
    public void InicializarListener() {
        //Adicionar escutado ao componente
        textFieldConsultar.addKeyListener(pesquisaDados);
        comboBoxProduto.addItemListener(comboBoxProdutoListener);
        comboBoxTabela.addItemListener(comboBoxTabelaListener);
    }

    @Override
    public void Start() {
        Consultar();
        InicializarListener();
        CarregarDadosComboBox(model, null);
        setExtendedState(MAXIMIZED_BOTH);
        setFiltroCampo();
        model.setNomeTela(getTitle());
    }

    @Override
    public boolean ValidaCampos() {
        if (!UtilitariosCampos.getValidarCampos(jPanelManutencaoA)) {
            tabbedPaneManutencao.setSelectedIndex(1);
            return false;
        } else if (!UtilitariosCampos.getValidarCampos(jPanelManutencaoB)) {
            tabbedPaneManutencao.setSelectedIndex(2);
            return false;
        } else {
            return true;
        }
    }

    @Override
    public void CarregarDadosComboBox(AssociarColunaVersaoModel model, String actionScript) {
        ProdutoController produtoControl = new ProdutoController();
        ProdutoModel produtoModel = produtoControl.getModel();
        produtoModel.setActionScript("C");
        comboBoxProduto.setModel(produtoControl.getDadosComboBoxModel(produtoModel));
    }

    @Override
    public void setFiltroCampo() {
        textFieldConsultar.setDocument(new setFiltroCampo(50, "LetraNumeroRealEspaco"));
        textFieldTamanho.setDocument(new setFiltroCampo(10, "NumeroReal"));
        textFieldValorPadrao.setDocument(new setFiltroCampo(50, "LetraNumeroRealEspaco"));
        textAreaSQL.setDocument(new setFiltroCampo(429496729, "Texto", 'P'));
    }
}
